/*
 * Copyright (C) 2001-2008  Nishanth Menon <menon.nishanth at gmail dot com>
 *
 * Part of the predict two project done during NITC Final year.
 * Predict2: http://code.google.com/p/predict2/
 * NITC: http://web.nitc.ac.in/~cse/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
 */

package kuberan;
import kuberan.*;
import java.util.Vector;
import utils.crypto.*;

public class deleteUser
{
    public static void help ()
    {
        System.err.println ("Usage");
        System.err.println (" deleteUser <UserName>");
        System.err.println ("");
        System.err.println ("");
    }
    public static void main (String[]args) throws Exception
    {
        if (args.length != 1)
          {
              System.err.println ("Arguments Not enough");
              help ();
              System.exit (1);
          }

        try
        {
            String UserName = args[0].trim ();
            KuberanInitialize j = new KuberanInitialize ("conf/kuberantest.conf");
            KuberanDataBaseAccess a = new KuberanDataBaseAccess (j);

            System.out.println ("Deleting from Password Table -" + UserName);
            a.DeletePasswordEntry (UserName);   // Okay

            Vector d = a.GetTransactionEntry (UserName);

            System.out.println ("Transactions in the Name of UserName=" + UserName);
            for (int i = 0; i < d.size (); i++)
                System.out.println (d.elementAt (i));
            a.DeleteTransactionEntry (UserName);

            d = a.GetPersonalInformationEntry (UserName);
            System.out.println ("PersonalInformations in the Name of UserName=" + UserName);
            for (int i = 0; i < d.size (); i++)
                System.out.println (d.elementAt (i));
            a.DeletePersonalInformationEntry (UserName);

            System.out.println ("Deletion Completed Successfully");
            a.close ();
        }
        catch (Exception e)
        {
            System.err.println ("ERRROR---" + e);
            e.printStackTrace ();
            help ();
        }
        System.exit (0);
    }
}
